package yaq.mini.weibo.leafwb.mapper;

import yaq.mini.weibo.leafwb.pojo.FavouriteCollection;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface FavouriteCollectionMapper {

    FavouriteCollection getFullFavouriteCollectionByID(String articleId, String userId);

    @Select("select * from favouriteCollection where articleId = #{articleId} and userId = #{userId}")
    FavouriteCollection getFavouriteCollectionByID(String userId, String articleId);

    @Select("select articleId from FavouriteCollection where userId=#{userId} and isLike=#{isLike}")
    List<String> getArticleIdsByLike(String userId, String isLike);

    @Select("select userId from FavouriteCollection where articleId=#{articleId} and isLike=#{isLike}")
    List<String> getUserIdsByLike(String articleId,String isLike);

    @Select("select articleId from FavouriteCollection where userId=#{userId} and isCollect=#{isCollect}")
    List<String> getArticleIdsByCollect(String userId, String isCollect);

    @Select("select articleId from FavouriteCollection where userId=#{userId} and isShield=#{isShield}")
    List<String> getArticleIdsByShield(String userId, String isShield);

    @Insert("insert into favouriteCollection values(#{userId},#{articleId},#{isLike},#{isCollect},#{isShield})")
    int insert(FavouriteCollection favouriteCollection);

    @Update("update favouriteCollection set isLike=#{isLike} where articleId=#{articleId} and userId=#{userId}")
    int updateLike(FavouriteCollection favouriteCollection);

    @Update("update favouriteCollection set isCollect=#{isCollect} where articleId=#{articleId} and userId=#{userId}")
    int updateCollect(FavouriteCollection favouriteCollection);

    @Update("update favouriteCollection set isShield=#{isShield} where articleId=#{articleId} and userId=#{userId}")
    int updateShield(FavouriteCollection favouriteCollection);

    @Delete("delete from favouriteCollection where articleId=#{articleId}")
    int deleteByAID(String articleId);
}
